﻿/*	ESTRUCTURA BD */
/*
	USE master;
	GO 
	DROP DATABASE electrondb;

	CREATE DATABASE electrondb;
	GO
	USE electrondb;
*/


CREATE TABLE region(
	id NUMERIC NOT NULL,
	nombre varchar(100),
	CONSTRAINT PK_region_id PRIMARY KEY(id)
);
 
CREATE TABLE provincia(
	id NUMERIC NOT NULL,
	nombre VARCHAR(100),
	region NUMERIC NOT NULL,
	CONSTRAINT PK_provincia_id PRIMARY KEY(id),
	CONSTRAINT FK_provincia_region_region_id FOREIGN KEY(region) REFERENCES region(id)
);

CREATE TABLE comuna(
	id NUMERIC NOT NULL,
	nombre VARCHAR(100),
	provincia NUMERIC NOT NULL,
	CONSTRAINT PK_comuna_id PRIMARY KEY(id),
	CONSTRAINT FK_comuna_provincia_provincia_id FOREIGN KEY(provincia) REFERENCES provincia(id)
);

CREATE TABLE options(
	id NUMERIC IDENTITY NOT NULL,
	key_option VARCHAR(25) UNIQUE,
	value_option VARCHAR(MAX)
);

CREATE TABLE estado(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX),
	CONSTRAINT PK_estado_id PRIMARY KEY(id)
);

CREATE TABLE tipousuario(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX),
	CONSTRAINT PK_tipousuarios_id PRIMARY KEY(id),
);

CREATE TABLE funcion(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX),
	descrip VARCHAR(MAX),
	CONSTRAINT PK_funcion_id PRIMARY KEY(id)
);

CREATE TABLE usuario(
	id NUMERIC IDENTITY NOT NULL,
	rut VARCHAR(12) NOT NULL UNIQUE,
	nombreReal VARCHAR(MAX),
	pswd VARCHAR(MAX),
	tipousuario NUMERIC NOT NULL,
	email VARCHAR(MAX) NULL,
	activo NUMERIC NOT NULL DEFAULT 1,
	CONSTRAINT PK_usuario_id PRIMARY KEY(id),
	CONSTRAINT FK_usuario_tipousuario_tipousuario_id FOREIGN KEY(tipousuario) REFERENCES tipousuario(id),
	CONSTRAINT FK_usuario_activo_estado_id FOREIGN KEY(activo) REFERENCES estado(id)
);

CREATE TABLE permisos(
	id NUMERIC IDENTITY NOT NULL,
	funcion NUMERIC NOT NULL,
	usuario NUMERIC NOT NULL,
	valor NUMERIC NOT NULL DEFAULT 1,
	CONSTRAINT PK_permisos_id PRIMARY KEY(id),
	CONSTRAINT FK_permisos_funcion_funcion_id FOREIGN KEY(funcion) REFERENCES funcion(id),
	CONSTRAINT FK_permisos_usuario_usuario_id FOREIGN KEY(usuario) REFERENCES usuario(id),
);

CREATE TABLE proveedor(
	id NUMERIC IDENTITY NOT NULL,
	rut CHAR(12) NOT NULL,
	nombre VARCHAR(MAX),
	giro VARCHAR(MAX),
	vendedor VARCHAR(MAX),
	telefono VARCHAR(20),
	direccion1 VARCHAR(MAX),
	direccion2 VARCHAR(MAX),
	email VARCHAR(MAX),
	comuna NUMERIC NOT NULL,
	creado DATETIME,
	nota VARCHAR(MAX),
	estado NUMERIC NOT NULL DEFAULT 1,
	CONSTRAINT PK_proveedor_id PRIMARY KEY(id),
	CONSTRAINT FK_proveedor_estado_estado_id FOREIGN KEY(estado) REFERENCES estado(id),
	CONSTRAINT FK_proveedor_comuna_comuna_id FOREIGN KEY(comuna) REFERENCES comuna(id)
);

CREATE TABLE marca(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX) NOT NULL,
	CONSTRAINT PK_marca_id PRIMARY KEY(id)
);

CREATE TABLE producto(
	id NUMERIC IDENTITY NOT NULL,
	codigobarras VARCHAR(MAX) DEFAULT '',
	descripcion VARCHAR(MAX),
	tipoprod NUMERIC NOT NULL DEFAULT 0,
	fechaCreado DATETIME,
	marca NUMERIC NOT NULL,
	comentarios VARCHAR(MAX),
	minimo NUMERIC,
	CONSTRAINT PK_producto_id PRIMARY KEY(id),
	CONSTRAINT FK_producto_marca_marca_id FOREIGN KEY(marca) REFERENCES marca(id)
);

CREATE TABLE precio(
	id NUMERIC IDENTITY NOT NULL,
	producto NUMERIC NOT NULL,
	fechaCreado DATETIME,
	costo MONEY DEFAULT 0,
	utilidad NUMERIC DEFAULT 0,
	impuesto NUMERIC DEFAULT 0,
	precioventa MONEY DEFAULT 0,
	cantidad NUMERIC NOT NULL,
	cactual NUMERIC NOT NULL,
	valido NUMERIC NOT NULL DEFAULT 0,
	CONSTRAINT PK_precio_id PRIMARY KEY(id),
	CONSTRAINT FK_precio_producto_producto_id FOREIGN KEY(producto) REFERENCES producto(id)
);

CREATE TABLE tipopago(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX),
	CONSTRAINT PK_tipopago_id PRIMARY KEY(id)
);

CREATE TABLE compra(
	id NUMERIC IDENTITY NOT NULL,
	orden VARCHAR(MAX),
	usuario NUMERIC NOT NULL,
	proveedor NUMERIC NOT NULL,
	fechapedido DATETIME NOT NULL,
	comentarios VARCHAR(MAX),
	tipopago NUMERIC NOT NULL,
	estado NUMERIC NOT NULL DEFAULT 0,
	fechaPago DATETIME DEFAULT NULL,
	CONSTRAINT PK_compra_id PRIMARY KEY(id),
	CONSTRAINT FK_compra_usuario_usuario_id FOREIGN KEY(usuario) REFERENCES usuario(id),
	CONSTRAINT FK_compra_proveedor_proveedor_id FOREIGN KEY(proveedor) REFERENCES proveedor(id),
	CONSTRAINT FK_compra_tipopago_tipopago_id FOREIGN KEY(tipopago) REFERENCES tipopago(id),
	CONSTRAINT FK_compra_estado_estado_id FOREIGN KETiY(proveedor) REFERENCES proveedor(id)
);

CREATE TABLE detallecompra(
	id NUMERIC IDENTITY NOT NULL,
	idcompra NUMERIC NOT NULL,
	idprecio NUMERIC NOT NULL,
	CONSTRAINT PK_detallecompra_id PRIMARY KEY(id),
	CONSTRAINT FK_detallecompra_idcompra_compra_id FOREIGN KEY(idcompra) REFERENCES compra(id),
	CONSTRAINT FK_detallecompra_idprecio_precio_id FOREIGN KEY(idprecio) REFERENCES precio(id)
);

CREATE TABLE tipodocumento(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX),
	CONSTRAINT PK_tipodocumento PRIMARY KEY(id)
);

CREATE TABLE venta(
	id NUMERIC IDENTITY NOT NULL,
	fechaVenta DATETIME NOT  NULL,
	tipodocumento NUMERIC NOT NULL,
	documento VARCHAR(MAX) NOT NULL,
	usuario NUMERIC NOT NULL,
	estado NUMERIC NOT NULL DEFAULT 0,
	fechaPago DATETIME NOT NULL,
	tipoPago NUMERIC NOT NULL,	
	comentario VARCHAR(MAX), 
	CONSTRAINT PK_venta_id PRIMARY KEY(id),
	CONSTRAINT FK_venta_usuario_usuario_id FOREIGN KEY (usuario) REFERENCES  usuario(id),
	CONSTRAINT FK_venta_estado_estado_id FOREIGN KEY (estado) REFERENCES estado(id),
	CONSTRAINT FK_venta_tipodocumento_tipodocumento_id FOREIGN KEY (tipodocumento) REFERENCES tipodocumento(id),
	CONSTRAINT FK_venta_tipopago_tipopago_id FOREIGN KEY (tipopago) REFERENCES tipopago(id)
);

CREATE TABLE tipoServicio(
	id NUMERIC IDENTITY NOT NULL,
	descripcion VARCHAR(MAX),
	CONSTRAINT PK_tipoServicio_id PRIMARY KEY(id)
);

CREATE TABLE servicio(
	id NUMERIC IDENTITY NOT NULL,
	tipoServicio NUMERIC NOT NULL,
	/*valorServicio*/
);

CREATE TABLE servicioVenta(
	id NUMERIC IDENTITY NOT NULL,
	idVenta NUMERIC NOT NULL,
	idServicio NUMERIC NOT NULL
);

CREATE TABLE detalleVenta (
	id NUMERIC IDENTITY NOT NULL,
	idPrecio NUMERIC NOT NULL,
	idVenta NUMERIC NOT NULL,
	cantidad NUMERIC NOT NULL,
	descuento NUMERIC NOT NULL,
	
	CONSTRAINT PK_detalleVenta_id PRIMARY KEY(id),
	CONSTRAINT FK_detalleVenta_idPrecio_precio_id FOREIGN KEY (idPrecio) REFERENCES precio(id),
	CONSTRAINT FK_detalleVenta_idVenta_venta_id FOREIGN KEY (idVenta) REFERENCES venta(id)
);


/*******************************DATOS********************************/

INSERT INTO tipodocumento VALUES('BOLETA'),('FACTURA')

INSERT INTO region
VALUES
(1000,'Region de Tarapaca'),
(2000,'Region de Antofagasta'),
(3000,'Region de Atacama'),
(4000,'Region de Coquimbo'),
(5000,'Region de Valparaiso'),
(6000,'Region del Libertador General Bernardo O'''+'higgins'),
(7000,'Region del Maule'),
(8000,'Region del Bio-Bio'),
(9000,'Region de la Araucanía'),
(10000,'Region de los Lagos'),
(11000,'Region de Aysen del General Carlos Ibañez del Campo'),
(12000,'Region de Magallanes y la Antartica Chilena'),
(13000,'Region Metropolitana de Santiago'),
(14000,'Region de los Rios'),
(15000,'Region de Arica y Parinacota')

INSERT INTO provincia
VALUES
		(1100,'Iquique',1000),
	    (2100,'Antofagasta',2000),
	    (2200,'El Loa',2000),
	    (2300,'Tocopilla',2000),
	    (3100,'Copiapó',3000),
	    (3200,'Chañaral',3000),
	    (3300,'Huasco',3000),
	    (4100,'Elqui',4000),
	    (4200,'Choapa',4000),
	    (4300,'Limarí',4000),
	    (5100,'Valparaíso',5000),
	    (5200,'Isla de Pascua',5000),
	    (5300,'Los Andes',5000),
	    (5400,'Petorca',5000),
	    (5500,'Quillota',5000),
	    (5600,'San Antonio',5000),
	    (5700,'San Felipe de Aconcagua',5000),
	    (6100,'Cachapoal',6000),
	    (6200,'Cardenal Caro',6000),
	    (6300,'Colchagua',6000),
	    (7100,'Talca',7000),
	    (7200,'Cauquenes',7000),
	    (7300,'Curicó',7000),
	    (7400,'Linares',7000),
	    (8100,'Concepción',8000),
	    (8200,'Arauco',8000),
	    (8300,'Biobío',8000),
	    (8400,'Ñuble',8000),
	    (9100,'Cautín',9000),
	    (9200,'Malleco',9000),
	    (10100,'Llanquihue',10000),
	    (10200,'Chiloé',10000),
	    (10300,'Osorno',10000),
	    (10400,'Palena',10000),
	    (11100,'Coihaique',11000),
	    (11200,'Aisén',11000),
	    (11300,'Capitán Prat',11000),
	    (11400,'General Carrera',11000),
	    (12100,'Magallanes',12000),
	    (12200,'Antártica Chilena',12000),
	    (12300,'Tierra del Fuego',12000),
	    (12400,'Última Esperanza',12000),
	    (13100,'Santiago',13000),
	    (13200,'Cordillera',13000),
	    (13300,'Chacabuco',13000),
	    (13400,'Maipo',13000),
	    (13500,'Melipilla',13000),
	    (13600,'Talagante',13000),
	    (14100,'Valdivia',14000),
	    (14200,'Ranco',14000),
	    (15100,'Arica',15000),
	    (15200,'Parinacota',15000)
	    
INSERT INTO comuna
VALUES
	  (1101,'Iquique',1100),
	  (1102,'Camiña',1100),
	  (1103,'Colchane',1100),
	  (1104,'Huara',1100),
	  (1105,'Pica',1100),
	  (1106,'Pozo Almonte',1100),
	  (2101,'Antofagasta',2100),
	  (2102,'Mejillones',2100),
	  (2103,'Sierra Gorda',2100),
	  (2104,'Taltal',2100),
	  (2201,'Calama',2200),
	  (2202,'Ollagüe',2200),
	  (2203,'San Pedro de Atacama',2200),
	  (2301,'Tocopilla',2300),
	  (2302,'María Elena',2300),
	  (3101,'Copiapó',3100),
	  (3102,'Caldera',3100),
	  (3103,'Tierra Amarilla',3100),
	  (3201,'Chañaral',3200),
	  (3202,'Diego de Almagro',3200),
	  (3301,'Vallenar',3300),
	  (3302,'Alto del Carmen',3300),
	  (3303,'Freirina',3300),
	  (3304,'Huasco',3300),
	  (4101,'La Serena',4100),
	  (4102,'Coquimbo',4100),
	  (4103,'Andacollo',4100),
	  (4104,'La Higuera',4100),
	  (4105,'Paiguano',4100),
	  (4106,'Vicuña',4100),
	  (4201,'Illapel',4200),
	  (4202,'Canela',4200),
	  (4203,'Los Vilos',4200),
	  (4204,'Salamanca',4200),
	  (4301,'Ovalle',4300),
	  (4302,'Combarbalá',4300),
	  (4303,'Monte Patria',4300),
	  (4304,'Punitaqui',4300),
	  (4305,'Río Hurtado',4300),
	  (5101,'Valparaíso',5100),
	  (5102,'Casablanca',5100),
	  (5103,'Concón',5100),
	  (5104,'Juan Fernández',5100),
	  (5105,'Puchuncaví',5100),
	  (5106,'Quilpué',5100),
	  (5107,'Quintero',5100),
	  (5108,'Villa Alemana',5100),
	  (5109,'Viña del Mar',5100),
	  (5201,'Isla de Pascua',5200),
	  (5301,'Los Andes',5300),
	  (5302,'Calle Larga',5300),
	  (5303,'Rinconada',5300),
	  (5304,'San Esteban',5300),
	  (5401,'La Ligua',5400),
	  (5402,'Cabildo',5400),
	  (5403,'Papudo',5400),
	  (5404,'Petorca',5400),
	  (5405,'Zapallar',5400),
	  (5501,'Quillota',5500),
	  (5502,'Calera',5500),
	  (5503,'Hijuelas',5500),
	  (5504,'La Cruz',5500),
	  (5505,'Limache',5500),
	  (5506,'Nogales',5500),
	  (5507,'Olmué',5500),
	  (5601,'San Antonio',5600),
	  (5602,'Algarrobo',5600),
	  (5603,'Cartagena',5600),
	  (5604,'El Quisco',5600),
	  (5605,'El Tabo',5600),
	  (5606,'Santo Domingo',5600),
	  (5701,'San Felipe',5700),
	  (5702,'Catemu',5700),
	  (5703,'Llaillay',5700),
	  (5704,'Panquehue',5700),
	  (5705,'Putaendo',5700),
	  (5706,'Santa María',5700),
	  (6101,'Rancagua',6100),
	  (6102,'Codegua',6100),
	  (6103,'Coinco',6100),
	  (6104,'Coltauco',6100),
	  (6105,'Doñihue',6100),
	  (6106,'Graneros',6100),
	  (6107,'Las Cabras',6100),
	  (6108,'Machalí',6100),
	  (6109,'Malloa',6100),
	  (6110,'Mostazal',6100),
	  (6111,'Olivar',6100),
	  (6112,'Peumo',6100),
	  (6113,'Pichidegua',6100),
	  (6114,'Quinta de Tilcoco',6100),
	  (6115,'Rengo',6100),
	  (6116,'Requínoa',6100),
	  (6117,'San Vicente',6100),
	  (6201,'Pichilemu',6200),
	  (6202,'La Estrella',6200),
	  (6203,'Litueche',6200),
	  (6204,'Marchihue',6200),
	  (6205,'Navidad',6200),
	  (6206,'Paredones',6200),
	  (6301,'San Fernando',6300),
	  (6302,'Chépica',6300),
	  (6303,'Chimbarongo',6300),
	  (6304,'Lolol',6300),
	  (6305,'Nancagua',6300),
	  (6306,'Palmilla',6300),
	  (6307,'Peralillo',6300),
	  (6308,'Placilla',6300),
	  (6309,'Pumanque',6300),
	  (6310,'Santa Cruz',6300),
	  (7101,'Talca',7100),
	  (7102,'Constitución',7100),
	  (7103,'Curepto',7100),
	  (7104,'Empedrado',7100),
	  (7105,'Maule',7100),
	  (7106,'Pelarco',7100),
	  (7107,'Pencahue',7100),
	  (7108,'Río Claro',7100),
	  (7109,'San Clemente',7100),
	  (7110,'San Rafael',7100),
	  (7201,'Cauquenes',7200),
	  (7202,'Chanco',7200),
	  (7203,'Pelluhue',7200),
	  (7301,'Curicó',7300),
	  (7302,'Hualañé',7300),
	  (7303,'Licantén',7300),
	  (7304,'Molina',7300),
	  (7305,'Rauco',7300),
	  (7306,'Romeral',7300),
	  (7307,'Sagrada Familia',7300),
	  (7308,'Teno',7300),
	  (7309,'Vichuquén',7300),
	  (7401,'Linares',7400),
	  (7402,'Colbún',7400),
	  (7403,'Longaví',7400),
	  (7404,'Parral',7400),
	  (7405,'Retiro',7400),
	  (7406,'San Javier',7400),
	  (7407,'Villa Alegre',7400),
	  (7408,'Yerbas Buenas',7400),
	  (8101,'Concepción',8100),
	  (8102,'Coronel',8100),
	  (8103,'Chiguayante',8100),
	  (8104,'Florida',8100),
	  (8105,'Hualqui',8100),
	  (8106,'Lota',8100),
	  (8107,'Penco',8100),
	  (8108,'San Pedro de La Paz',8100),
	  (8109,'Santa Juana',8100),
	  (8110,'Talcahuano',8100),
	  (8111,'Tomé',8100),
	  (8201,'Lebu',8200),
	  (8202,'Arauco',8200),
	  (8203,'Cañete',8200),
	  (8204,'Contulmo',8200),
	  (8205,'Curanilahue',8200),
	  (8206,'Los Alamos',8200),
	  (8207,'Tirúa',8200),
	  (8301,'Los Angeles',8300),
	  (8302,'Antuco',8300),
	  (8303,'Cabrero',8300),
	  (8304,'Laja',8300),
	  (8305,'Mulchén',8300),
	  (8306,'Nacimiento',8300),
	  (8307,'Negrete',8300),
	  (8308,'Quilaco',8300),
	  (8309,'Quilleco',8300),
	  (8310,'San Rosendo',8300),
	  (8311,'Santa Bárbara',8300),
	  (8312,'Tucapel',8300),
	  (8313,'Yumbel',8300),
	  (8401,'Chillán',8400),
	  (8402,'Bulnes',8400),
	  (8403,'Cobquecura',8400),
	  (8404,'Coelemu',8400),
	  (8405,'Coihueco',8400),
	  (8406,'Chillán Viejo',8400),
	  (8407,'El Carmen',8400),
	  (8408,'Ninhue',8400),
	  (8409,'Ñiquén',8400),
	  (8410,'Pemuco',8400),
	  (8411,'Pinto',8400),
	  (8412,'Portezuelo',8400),
	  (8413,'Quillón',8400),
	  (8414,'Quirihue',8400),
	  (8415,'Ránquil',8400),
	  (8416,'San Carlos',8400),
	  (8417,'San Fabián',8400),
	  (8418,'San Ignacio',8400),
	  (8419,'San Nicolás',8400),
	  (8420,'Treguaco',8400),
	  (8421,'Yungay',8400),
	  (9101,'Temuco',9100),
	  (9102,'Carahue',9100),
	  (9103,'Cunco',9100),
	  (9104,'Curarrehue',9100),
	  (9105,'Freire',9100),
	  (9106,'Galvarino',9100),
	  (9107,'Gorbea',9100),
	  (9108,'Lautaro',9100),
	  (9109,'Loncoche',9100),
	  (9110,'Melipeuco',9100),
	  (9111,'Nueva Imperial',9100),
	  (9112,'Padre las Casas',9100),
	  (9113,'Perquenco',9100),
	  (9114,'Pitrufquén',9100),
	  (9115,'Pucón',9100),
	  (9116,'Saavedra',9100),
	  (9117,'Teodoro Schmidt',9100),
	  (9118,'Toltén',9100),
	  (9119,'Vilcún',9100),
	  (9120,'Villarrica',9100),
	  (9201,'Angol',9200),
	  (9202,'Collipulli',9200),
	  (9203,'Curacautín',9200),
	  (9204,'Ercilla',9200),
	  (9205,'Lonquimay',9200),
	  (9206,'Los Sauces',9200),
	  (9207,'Lumaco',9200),
	  (9208,'Purén',9200),
	  (9209,'Renaico',9200),
	  (9210,'Traiguén',9200),
	  (9211,'Victoria',9200),
	  (10101,'Puerto Montt',10100),
	  (10102,'Calbuco',10100),
	  (10103,'Cochamó',10100),
	  (10104,'Fresia',10100),
	  (10105,'Frutillar',10100),
	  (10106,'Los Muermos',10100),
	  (10107,'Llanquihue',10100),
	  (10108,'Maullín',10100),
	  (10109,'Puerto Varas',10100),
	  (10201,'Castro',10200),
	  (10202,'Ancud',10200),
	  (10203,'Chonchi',10200),
	  (10204,'Curaco de Vélez',10200),
	  (10205,'Dalcahue',10200),
	  (10206,'Puqueldón',10200),
	  (10207,'Queilén',10200),
	  (10208,'Quellón',10200),
	  (10209,'Quemchi',10200),
	  (10210,'Quinchao',10200),
	  (10301,'Osorno',10300),
	  (10302,'Puerto Octay',10300),
	  (10303,'Purranque',10300),
	  (10304,'Puyehue',10300),
	  (10305,'Río Negro',10300),
	  (10306,'San Juan de La Costa',10300),
	  (10307,'San Pablo',10300),
	  (10401,'Chaitén',10400),
	  (10402,'Futaleufú',10400),
	  (10403,'Hualaihué',10400),
	  (10404,'Palena',10400),
	  (11101,'Coihaique',11100),
	  (11102,'Lago Verde',11100),
	  (11201,'Aisén',11200),
	  (11202,'Cisne',11200),
	  (11203,'Guaitecas',11200),
	  (11301,'Cochrane',11300),
	  (11302,'O'''+'Higgins',11300),
	  (11303,'Tortel',11300),
	  (11401,'Chile Chico',11400),
	  (11402,'Río Ibáñez',11400),
	  (12101,'Punta Arenas',12100),
	  (12102,'Laguna Blanca',12100),
	  (12103,'Río Verde',12100),
	  (12104,'San Gregorio',12100),
	  (12201,'Cabo de Horno',12200),
	  (12202,'Antártica',12200),
	  (12301,'Porvenir',12300),
	  (12302,'Primavera',12300),
	  (12303,'Timaukel',12300),
	  (12401,'Natales',12400),
	  (12402,'Torres del Paine',12400),
	  (13101,'Santiago',13100),
	  (13102,'Cerrillos',13100),
	  (13103,'Cerro Navia',13100),
	  (13104,'Conchalí',13100),
	  (13105,'El Bosque',13100),
	  (13106,'Estación Central',13100),
	  (13107,'Huechuraba',13100),
	  (13108,'Independencia',13100),
	  (13109,'La Cisterna',13100),
	  (13110,'La Florida',13100),
	  (13111,'La Granja',13100),
	  (13112,'La Pintana',13100),
	  (13113,'La Reina',13100),
	  (13114,'Las Condes',13100),
	  (13115,'Lo Barnechea',13100),
	  (13116,'Lo Espejo',13100),
	  (13117,'Lo Prado',13100),
	  (13118,'Macul',13100),
	  (13119,'Maipú',13100),
	  (13120,'Ñuñoa',13100),
	  (13121,'Pedro Aguirre Cerda',13100),
	  (13122,'Peñalolén',13100),
	  (13123,'Providencia',13100),
	  (13124,'Pudahuel',13100),
	  (13125,'Quilicura',13100),
	  (13126,'Quinta Normal',13100),
	  (13127,'Recoleta',13100),
	  (13128,'Renca',13100),
	  (13129,'San Joaquín',13100),
	  (13130,'San Miguel',13100),
	  (13131,'San Ramón',13100),
	  (13132,'Vitacura',13100),
	  (13201,'Puente Alto',13200),
	  (13202,'Pirque',13200),
	  (13203,'San José de Maipo',13200),
	  (13301,'Colina',13300),
	  (13302,'Lampa',13300),
	  (13303,'Tiltil',13300),
	  (13401,'San Bernardo',13400),
	  (13402,'Buin',13400),
	  (13403,'Calera de Tango',13400),
	  (13404,'Paine',13400),
	  (13501,'Melipilla',13500),
	  (13502,'Alhué',13500),
	  (13503,'Curacaví',13500),
	  (13504,'María Pinto',13500),
	  (13505,'San Pedro',13500),
	  (13601,'Talagante',13600),
	  (13602,'El Monte',13600),
	  (13603,'Isla de Maipo',13600),
	  (13604,'Padre Hurtado',13600),
	  (13605,'Peñaflor',13600),
	  (14101,'Valdivia',14100),
	  (14102,'Corral',14100),
	  (14103,'Futrono',14100),
	  (14104,'La Unión',14100),
	  (14105,'Lago Ranco',14100),
	  (14106,'Lanco',14100),
	  (14107,'Los Lagos',14100),
	  (14108,'Máfil',14100),
	  (14109,'Mariquina',14100),
	  (14110,'Paillaco',14100),
	  (14111,'Panguipulli',14100),
	  (14112,'Río Bueno',14100),
	  (14201,'La Union',14200),
	  (14202,'Futrono',14200),
	  (14203,'Lago Ranco',14200),
	  (14204,'Rio Bueno',14200),
	  (15101,'Arica',15100),
	  (15102,'Camarones',15100),
	  (15201,'Putre',15200),
	  (15202,'General Lagos',15200)


INSERT INTO estado VALUES('ACTIVO'),('CANCELADO')

INSERT INTO tipousuario VALUES('ADMINISTRADOR'),('VENDEDOR'),('BODEGUERO');


INSERT INTO funcion VALUES('FrmProveedores','Otorga acceso al formulario de Proveedores.');
INSERT INTO funcion VALUES('FrmUsuarios','Otorga acceso al formulario de Usuarios.');
INSERT INTO funcion VALUES('FrmPermisos','Otorga acceso al formulario de Permisos.');
INSERT INTO funcion VALUES('FrmCompras','Otorga acceso al formulario de Compras.');
INSERT INTO funcion VALUES('FunProveedoresAgregar','Permite agregar nuevos proveedores.');
INSERT INTO funcion VALUES('FunProveedoresModificar','Permite modificar proveedores.');

INSERT INTO usuario VALUES('11.111.111-1','Administrador','163c6908ac2637c429289d9fca42cfa431d7bb636fced126c34be6b157fe795f8a87bc8d5b8cff1dc6b7ea9ee7a136097158efce34a38d8ccefef118aad89cb0',1,'administrador@email.com',1);
INSERT INTO usuario VALUES('22.222.222-2','Juan Perez','163c6908ac2637c429289d9fca42cfa431d7bb636fced126c34be6b157fe795f8a87bc8d5b8cff1dc6b7ea9ee7a136097158efce34a38d8ccefef118aad89cb0',2,'jperez@email.com',1);
INSERT INTO usuario VALUES('33.333.333-3','Maria Soto','163c6908ac2637c429289d9fca42cfa431d7bb636fced126c34be6b157fe795f8a87bc8d5b8cff1dc6b7ea9ee7a136097158efce34a38d8ccefef118aad89cb0',2,'msoto@email.com',1);

INSERT INTO proveedor VALUES('11111111-1','CODIGO-SOURCE.NET','SERVICIOS COMPUTACIONALES','JOSE PEREZ','227737','RUTA H30 #1522','VILLA EL COBRE','jose.perez@codigo-source.net',6101,'20110101','NOTA PRUEBA CODIGO_SOURCE',DEFAULT)
INSERT INTO proveedor VALUES('22222222-2','INACAP RANCAGUA','ENSEÑANZA','ESTEBAN OLEA','326380','CALLE ASDF #1521','VILLA NO C CUANTO','eolea@inacap.cl',6102,'20110101','NOTA PRUEBA INACAP',DEFAULT)
INSERT INTO proveedor VALUES('33333333-3','PCFATORY','VENTA DE PRODUCTOS DE COMPUTACION ','JUAN PEREZ','145156','SAN MARTIN 123','CENTRO','juanperez@pcfactory.cl',6101,'20110101','NOTA PRUEBA PCFACTORY',DEFAULT)

INSERT INTO permisos VALUES(1,1,1),(1,2,1),(1,3,1),(2,1,1),(2,2,0),(2,3,1),(3,1,1),(3,2,0),(3,3,1),(4,1,1),(4,2,0),(4,3,1),(5,1,1),(5,2,0),(5,3,1),(6,1,1),(6,2,0),(6,3,1)
INSERT INTO tipopago VALUES('EFECTIVO'),('CUOTAS'),('CHEQUE AL DIA'),('CHEQUE 30 DIAS'),('VISA')



